package practice1_100;

import java.util.Arrays;

public class Practice324 {
    public void wiggleSort(int[] nums) {
        Arrays.sort(nums);
        //System.out.println(nums);
        int len=nums.length;
        int halfOflength= len/2==0? len/2: (len+1)/2;
        int[] Copynums=Arrays.copyOf(nums,len);
        //nums长度为奇数时，
        for (int i=0;i<halfOflength;i++){
            if(i*2<= len-1){
                nums[i*2]=Copynums[i];
            }
            if(i*2+1<=len-1){
                nums[i*2+1]=Copynums[halfOflength+i];
            }
        }
        System.out.println(nums);
    }

    public static void main(String[] args) {
        new Practice324().wiggleSort(new int[] {1,6,264,46,56,5,4,2,8});

    }
}
